package com.lzcangqiong.design.patterns.factory.simple;


import java.util.Date;

/**
 * Created by luozhen on 2018/6/14.
 */
public class Example {

    private String name = "zhangfei";

    public Example() {

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        //Class.forName("");是典型的静态工厂方法，根据传入的类名返回具体的类对象
        Class clazz = Class.forName("com.lzcangqiong.design.patterns.factory.simple.Example");
        Example obj = (Example)clazz.newInstance();
        System.out.println(obj.getName());
        Class dateClass = Class.forName("java.util.Date");
        Date date = (Date) dateClass.newInstance();
        System.out.println(date);

        Class clazz2 = Class.forName("className");
    }
}
